package com.dstz.sys;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dstz.base.api.response.impl.ResultMsg;
import com.dstz.base.core.util.RestTemplateUtil;
import com.dstz.bus.api.remote.RemoteBusinessData;
import com.dstz.sys.util.HttpUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;

import java.io.IOException;

public class Test {

    public static void main(String[] args) throws IOException {
//        String s= HttpUtil.sendPost("http://119.3.167.118:8888/getAllDepartment.do","");
//        JSONObject jsonObject=JSON.parseObject(s);
//        JSONArray jsonArray=jsonObject.getJSONArray("msg");
//        jsonArray.forEach(j->{
//            JSONObject jsonObjec=JSON.parseObject(String.valueOf(j));
//            String showOrderOfTree=jsonObjec.getString("showOrderOfTree");
//            System.out.println(showOrderOfTree);
//        });
        HttpHeaders headers = new HttpHeaders();
        headers.add("Cookie", "JSESSIONID=272CE563F2E0AAC39A0D30B6A0A2416D");
        String url = "http://localhost:18084/org/group/save";
        RemoteBusinessData<JSONObject> remoteBusinessData = new RemoteBusinessData<>();
        JSONObject insetJosn=new JSONObject();
        insetJosn.put("code","12345");
        insetJosn.put("name","测试部");
        insetJosn.put("parentId","410054574497333249");
        insetJosn.put("parentName","信阳分公司");
        insetJosn.put("sn",1);
        remoteBusinessData.setData(insetJosn);
        HttpEntity<String> entity = new HttpEntity<>("abc", headers);
        ResultMsg<JSONObject> resp = RestTemplateUtil.post(url, remoteBusinessData, ResultMsg.class);
        System.out.println(resp);
    }
}
